#include "threadPool.h"
//假设ant长度为1024或更大
int func_ls(char * ant,stringStack_t * stack)
{
    ////////////////////////////////////////得到工作路径
    char work_path[100]={0};
    func_pwd(work_path,stack);
    char true_path[1024]={0};
    sprintf(true_path,"%s%s",ROOT_PATH,work_path);
    DIR * dirp = opendir(true_path);
    if(dirp==NULL)
    {
        printf("当前目录不存在");
        return -1;
    }
    struct dirent * pdirent;
    // 循环读目录项并打印目录信息，循环结束的条件是返回值为NULL   
    while((pdirent = readdir(dirp)) != NULL){
        char * now_name=pdirent->d_name;
        strcat(ant,now_name);
        strcat(ant," ");
    }
    // 及时释放资源，关闭目录流
    closedir(dirp);
    printf("%s\n",ant);
    return 0;
}

